/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.fb.FreeBusyProvider;
/*    */ import com.zimbra.cs.fb.FreeBusyProvider.FreeBusySyncQueue;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetFreeBusyQueueInfo
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 32 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/*    */ 
/* 35 */     checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
/*    */     
/* 37 */     String name = null;
/* 38 */     Element provider = request.getOptionalElement("provider");
/* 39 */     if (provider != null) {
/* 40 */       name = provider.getAttribute("name");
/*    */     }
/* 42 */     Element response = zsc.createElement(AdminConstants.GET_FREE_BUSY_QUEUE_INFO_RESPONSE);
/* 43 */     if (name != null) {
/* 44 */       FreeBusyProvider prov = FreeBusyProvider.getProvider(name);
/* 45 */       if (prov == null)
/* 46 */         throw ServiceException.INVALID_REQUEST("provider not found: " + name, null);
/* 47 */       handleProvider(response, prov);
/*    */     } else {
/* 49 */       for (FreeBusyProvider prov : FreeBusyProvider.getProviders()) {
/* 50 */         handleProvider(response, prov);
/*    */       }
/*    */     }
/* 53 */     return response;
/*    */   }
/*    */   
/* 56 */   private void handleProvider(Element response, FreeBusyProvider prov) { Element provider = response.addElement("provider");
/* 57 */     provider.addAttribute("name", prov.getName());
/* 58 */     FreeBusyProvider.FreeBusySyncQueue queue = prov.getSyncQueue();
/* 59 */     if (queue == null)
/* 60 */       return;
/* 61 */     synchronized (queue) {
/* 62 */       for (String id : queue) {
/* 63 */         provider.addElement("account").addAttribute("id", id);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes) {
/* 69 */     notes.add("Only system admins are allowed.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetFreeBusyQueueInfo.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */